The mapNotNull()
operator for Flow
works the same as map()
, except that
it discards any null
values returned by the conversion lambda expression.
The resulting Flow
from applying this operator will be of type T
, rather than T?
,
where T?
is whatever nullable type the lambda expression returns.
So, in this case, we still square the incoming values and convert them to strings,
but leave null
alone. mapNotNull()
will throw out those null
values, emitting
just the strings.
You can learn more about this in:
Tags: